// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: Gunnar Ritter

#ifndef POPDIAG_PROBES_IMAPPROBE_TEST_H_
#define POPDIAG_PROBES_IMAPPROBE_TEST_H_

#include <QtTest/QtTest>

#include "probes/probe.h"

namespace popdiag {

enum State {
  STATE_FAILED,
  STATE_WAITING,
  STATE_BANNER,
  STATE_CAPABILITY_LISTING,
  STATE_CAPABILITY_RESPONSE,
  STATE_LOGIN,
  STATE_SELECT_FLAGS,
  STATE_SELECT_EXISTS,
  STATE_SELECT_RECENT,
  STATE_SELECT_UNSEEN,
  STATE_SELECT_PERMANTENTFLAGS,
  STATE_SELECT_UIDNEXT,
  STATE_SELECT_UIDVALIDITY,
  STATE_SELECT_RESPONSE,
  STATE_FETCH_FLAGS1,
  STATE_FETCH_FLAGS2,
  STATE_EXPUNGE,
  STATE_FETCH_FLAGS_RESPONSE,
  STATE_FETCH_DATA1,
  STATE_FETCH_DATA_CONTENTS,
  STATE_FETCH_DATA_RPAREN,
  STATE_FETCH_DATA_RESPONSE,
  STATE_LOGOUT1,
  STATE_LOGOUT2,
  STATE_PASSED
};

enum Test {
  TEST_STANDARD_RUN,
  TEST_PULL_ALL_MAIL,
  TEST_PREAUTH,
  TEST_EXPUNGE,
  TEST_BANNER_FAILURE,
  TEST_CAPABILITY_FAILURE,
  TEST_LOGIN_FAILURE,
  TEST_SELECT_FAILURE,
  TEST_FETCH_FLAGS_FAILURE,
  TEST_FETCH_DATA_FAILURE,
  TEST_LOGOUT_FAILURE,
  TEST_MISSING_EXISTS,
};

enum Actions {
  ACTIONS_GOOD,
  ACTIONS_BAD
};

class TestImapProbe : public QObject {
  Q_OBJECT
 private slots:
  void TestStandardRun();
  void TestPullAllMail();
  void TestPreauth();
  void TestExpunge();
  void TestBannerFailure();
  void TestCapabilityFailure();
  void TestLoginFailure();
  void TestSelectFailure();
  void TestFetchFlagsFailure();
  void TestFetchDataFailure();
  void TestLogoutFailure();
  void TestMissingExists();
  void OnProbeComplete(ResultStatus result);

 private:
  void StartImapProbe();
  ResultStatus result_;
  bool probe_running_;
};

}  // namespace popdiag

#endif  // POPDIAG_PROBES_IMAPPROBE_TEST_H_
